<%! import cgi %>
<%inherit file="base.html"/>
<h2>
    ${profile_fields['generic']['name']['values'][0]['value']}
</h2>
% if is_self:
    <span class="tag self">${_('You')}</span>
% elif is_friend:
    <span class="tag friend">${_('Friend')}</span>
% else:
    <span class="tag">${_('Stranger')}</span>
% endif
<div class="lastUpdated">
    ${_('Updated:')} ${profile_fields['meta']['pretty_last_updated']}
</div>
<div id="leftPanel">
</div>
<div id="mainPanel">
    % if is_friend or is_self:
    <div class="section" id="updates">
        <h3>
            ${_('Event updates')}
            <span class="inlineNav">
                <a href="/person/">^ ${_('Back')}</a>
            </span>
        </h3>
        % if len(events_list['items']) > 0:
            <ul>
                % for event in events_list['items'][:4]:
                    <li>
                        <a href="http://${event['source_iid']}.hexlabel.net/">${event['source_name']}</a> :
                        ${event['comment']}
                        % if event['target_iid']:
                         - <a href="http://${event['target_iid']}.hexlabel.net/">${event['target_name']}</a>
                        % endif
                        <span class="ts">${event['pretty_timestamp']}</span>
                    </li>
                % endfor
            </ul>
        % endif

        <h3>
            ${_('Status updates')}
            <span class="inlineNav">
                <a href="/person/">^ ${_('Back')}</a>
            </span>
        </h3>
        % if len(status_list['items']) > 0:
            <ul>
                % for status in status_list['items']:
                    <li>
                        <a href="http://${status['source_iid']}.hexlabel.net/">${status['source_name']}</a> :
                        ${status['comment']}
                        <span class="ts">${status['pretty_timestamp']}</span>
                    </li>
                % endfor
            </ul>
        % endif

        <h3>
            ${_('Content updates')}
            <span class="inlineNav">
                <a href="/person/">^ ${_('Back')}</a>
            </span>
        </h3>
        % if len(atom_list['items']) > 0:
            <ul class="atomList">
                % for feed in atom_list['items']:
                    % if len(feed['entries']) > 0:
                        <li class="feed">
                            <h4>${('New content in')} <a href="http://${feed['id']}.hexlabel.net/">${feed['title']}</a></h4>
                            % if feed['parent']['iid'] != hexlabel:
                            <div class="parentInfo">Linked from <a href="http://${feed['parent']['iid']}.hexlabel.net">${feed['parent']['name']}</a></div>
                            % endif
                            % for entry in feed['entries']:
                                % if entry.has_key('link'):
                                    % if entry['link'].get('type') and entry['link']['type'].startswith('image/'):
                                        <p class="inline">
                                            <img src="${entry['link']['href']}" width="32" height="32" alt=""/>
                                        </p>
                                    % else:
                                        <p class="inline">
                                            <a href="${entry['link']['href']}">${entry['title']}</a>
                                        </p>
                                    % endif
                                % else:
                                    % if entry['title']:
                                        <h5>${entry['title']}</h5>
                                    % endif
                                    <p class="entry">
                                        ${nl2br_raw(entry['summary']) | n}
                                    </p>
                                    <div class="metadata">
                                        <p class="author"><a href="${entry['author']['uri']}">${entry['author']['name']}</a></p>
                                        <p class="updated">${entry['pretty_updated']}</p>
                                    </div>
                                % endif
                            % endfor
                            <div class="clr"><br/></div>
                        </li>
                    % endif
                % endfor
            </ul>
        % endif
    </div>
    % endif
</div>


<!-- defs -->
<%def name="title()">P2P Fusion - Peerscape | ${profile_fields['generic']['name']['values'][0]['value']}</%def>
<%def name="head()">
    <!--
    <script type="text/javascript" src="/static/js/jquery.min.js"></script>
    <script type="text/javascript">
        var peerscape = function() {
            return {
                init: function() {
                    // hide the invite alert message box if it exists
                    $('#notifications .collapse').hide();
                    $('#notifications #messageWrapper label')
                        .wrapInner('<a href="#"></a>')
                        .bind('click', function() {
                            $('#notifications #messageWrapper .collapse').slideDown("normal");
                            $('#notifications #messageWrapper label a')
                                .unbind('click')
                                .removeAttr('href')
                        });
                }
            }
        }();
        $(peerscape.init);
    </script>
    -->
</%def>
<%def name="body_class()">
    % if is_self:
  	    person self
    % elif is_friend:
  	    person friend
    % else:
  	    person
    % endif
</%def>
<%def name="extra_subtitle_content()">
    % if is_self:
        % if len(sync_sessions) == 1:
            (<a href="http://admin.hexlabel.net/#connectionsTable" title="${_('Click to see further connection details')}">${len(sync_sessions)} peer connection</a>)
        % else:
            (<a href="http://admin.hexlabel.net/#connectionsTable" title="${_('Click to see further connection details')}">${len(sync_sessions)} peer connections</a>)
        % endif
    % endif
</%def>

<%def name="notifications()">
    % if is_self and upgrade_recommended:
        <div class="item">
            <p><a href="https://addons.mozilla.org/firefox/addon/12054">A recommended update</a> ${_(' is available.')}</p>
            <p>${_('You are currently running Peerscape version ')}${current_version}${_('.')}</p>
        </div>
    % endif
</%def>

<%def name="displayField(section, field, num=0, is_email=False, is_link=False, is_long=False)">
    % if profile_fields.has_key(section) and profile_fields[section].has_key(field):
        % if (profile_fields[section][field]['values'][num]['visibility'] or is_self or is_friend) and profile_fields[section][field]['values'][num]['value']:
        <tr>
        % if is_long:
            <td class="long" colspan="2">
                % if is_self and profile_fields[section][field]['values'][num]['visibility']:
                    ${profile_fields[section][field]['meta']['label']}:<abbr title="Public field"><sup>*</sup></abbr>
                % else:
                    ${profile_fields[section][field]['meta']['label']}:
                % endif
                <span>
                    % if profile_fields[section][field]['values'][num]['value']:
                        % if is_email:
                            <a href="mailto:${profile_fields[section][field]['values'][num]['value']}">${profile_fields[section][field]['values'][num]['value']}</a>
                        % elif is_link:
                            % if profile_fields[section][field]['values'][num]['value'].startswith('http://'):
                                <a href="${profile_fields[section][field]['values'][num]['value']}" target="_blank">${profile_fields[section][field]['values'][num]['value']}</a>
                            % else:
                                <a href="http://${profile_fields[section][field]['values'][num]['value']}" target="_blank">${profile_fields[section][field]['values'][num]['value']}</a>
                            % endif
                        % else:
                            ${profile_fields[section][field]['values'][num]['value']}
                        % endif
                    % else:
                        --
                    % endif
                </span>
            </td>
        % else:
            <td class="label">
                % if is_self and profile_fields[section][field]['values'][num]['visibility']:
                    ${profile_fields[section][field]['meta']['label']}:<abbr title="Public field"><sup>*</sup></abbr>
                % else:
                    ${profile_fields[section][field]['meta']['label']}:
                % endif
            </td>
             <td class="value">
                % if profile_fields[section][field]['values'][num]['value']:
                    % if is_email:
                        <a href="mailto:${profile_fields[section][field]['values'][num]['value']}">${profile_fields[section][field]['values'][num]['value']}</a>
                    % elif is_link:
                        <a href="${profile_fields[section][field]['values'][num]['value']}" target="_blank">${profile_fields[section][field]['values'][num]['value']}</a>
                    % else:
                        ${profile_fields[section][field]['values'][num]['value']}
                    % endif
                % else:
                    --
                % endif
            </td>
        % endif
        </tr>
        % endif
    % endif
</%def>

<%def name="nl2br_raw(s)">
    ${'<br/>'.join(s.split("\n")) | n}
</%def>
<%def name="nl2br(s)">
    ${'<br/>'.join(cgi.escape(s).split("\n")) | n}
</%def>
